<template>
  <div class="home-view">
    <el-container class="home-container">
      <el-header class="home-header">
        <div class="header-content">
          <div class="logo">
            <h1>ReactIM</h1>
            <span class="tagline">即时通讯</span>
          </div>
          <div class="header-actions">
            <template v-if="!isAuthenticated">
              <el-button type="default" @click="goToRegister">
                注册
              </el-button>
              <el-button type="primary" @click="goToLogin">
                登录
              </el-button>
            </template>
            <el-button v-else type="primary" @click="goToChat">
              进入聊天
            </el-button>
          </div>
        </div>
      </el-header>
      
      <el-main class="home-main">
        <div class="hero-section">
          <div class="hero-content">
            <h2 class="hero-title">现代化的即时通讯体验</h2>
            <p class="hero-description">
              基于 Vue 3 和现代 Web 技术构建的高性能即时通讯应用，
              支持实时消息、文件传输、多设备同步等功能。
            </p>
            
            <div class="feature-grid">
              <div class="feature-item">
                <el-icon class="feature-icon" size="32">
                  <ChatDotRound />
                </el-icon>
                <h3>实时消息</h3>
                <p>基于 WebSocket 和 RSocket 的双重保障，确保消息实时送达</p>
              </div>
              
              <div class="feature-item">
                <el-icon class="feature-icon" size="32">
                  <Monitor />
                </el-icon>
                <h3>多端适配</h3>
                <p>响应式设计，完美适配手机、平板和桌面设备</p>
              </div>
              
              <div class="feature-item">
                <el-icon class="feature-icon" size="32">
                  <Lock />
                </el-icon>
                <h3>安全可靠</h3>
                <p>端到端加密，保护您的隐私和数据安全</p>
              </div>
              
              <div class="feature-item">
                <el-icon class="feature-icon" size="32">
                  <Lightning />
                </el-icon>
                <h3>高性能</h3>
                <p>虚拟滚动、懒加载等优化技术，流畅的使用体验</p>
              </div>
            </div>
            
            <div class="cta-section">
              <template v-if="!isAuthenticated">
                <el-button 
                  type="primary" 
                  size="large" 
                  @click="goToRegister"
                >
                  免费注册
                </el-button>
                <el-button 
                  type="default" 
                  size="large" 
                  @click="goToLogin"
                >
                  立即登录
                </el-button>
              </template>
              <el-button 
                v-else 
                type="primary" 
                size="large" 
                @click="goToChat"
              >
                进入聊天室
              </el-button>
            </div>
          </div>
        </div>
      </el-main>
      
      <el-footer class="home-footer">
        <div class="footer-content">
          <p>&copy; 2024 ReactIM. 基于 Vue 3 + TypeScript 构建</p>
          <div class="footer-links">
            <router-link to="/about">关于我们</router-link>
            <a href="https://github.com" target="_blank">GitHub</a>
          </div>
        </div>
      </el-footer>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import { 
  ChatDotRound, 
  Monitor, 
  Lock, 
  Lightning 
} from '@element-plus/icons-vue'

const router = useRouter()
const authStore = useAuthStore()

const isAuthenticated = computed(() => authStore.isAuthenticated)

const goToLogin = () => {
  router.push('/login')
}

const goToRegister = () => {
  router.push('/register')
}

const goToChat = () => {
  router.push('/chat')
}
</script>

<style scoped lang="scss">
.home-view {
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.home-container {
  height: 100%;
}

.home-header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.logo {
  h1 {
    margin: 0;
    font-size: 28px;
    font-weight: bold;
  }
  
  .tagline {
    font-size: 14px;
    opacity: 0.8;
    margin-left: 8px;
  }
}

.home-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.hero-section {
  max-width: 1200px;
  width: 100%;
  text-align: center;
}

.hero-title {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-description {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 60px;
  opacity: 0.9;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
  margin-bottom: 60px;
}

.feature-item {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 30px 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  }
  
  .feature-icon {
    color: #FFD700;
    margin-bottom: 16px;
  }
  
  h3 {
    font-size: 20px;
    margin-bottom: 12px;
    font-weight: 600;
  }
  
  p {
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.8;
  }
}

.cta-section {
  margin-top: 40px;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  
  .el-button {
    padding: 16px 32px;
    font-size: 16px;
    border-radius: 8px;
    min-width: 120px;
  }
}

.home-footer {
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  
  p {
    margin: 0;
    font-size: 14px;
    opacity: 0.7;
  }
}

.footer-links {
  display: flex;
  gap: 20px;
  
  a {
    color: white;
    text-decoration: none;
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    
    &:hover {
      opacity: 1;
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .header-content {
    padding: 0 16px;
  }
  
  .logo h1 {
    font-size: 24px;
  }
  
  .hero-title {
    font-size: 32px;
  }
  
  .hero-description {
    font-size: 16px;
    margin-bottom: 40px;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 40px;
  }
  
  .feature-item {
    padding: 20px 16px;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 0 16px;
  }
  
  .footer-links {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .header-content {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }
  
  .hero-title {
    font-size: 28px;
  }
  
  .home-main {
    padding: 20px 16px;
  }
}
</style>
